package com.example.dbsample.util.dynamicconnection;

import org.springframework.core.NamedThreadLocal;

public final class DynamicRedisSourceContextHolder {
    private static final ThreadLocal<String> TL_REDIS_SOURCE = new NamedThreadLocal<String>("dynamic-redis-source") {
        protected String initialValue() {
            return "";
        }
    };

    private DynamicRedisSourceContextHolder() {

    }

    public static void set(String redisSource) {
        TL_REDIS_SOURCE.set(redisSource);
    }

    public static String get() {
        return (String) TL_REDIS_SOURCE.get();
    }

    public static void clear() {
        TL_REDIS_SOURCE.remove();
    }
}
